import Vue from "vue";
import Cookies from 'js-cookie';
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

let _role=Cookies.get('roleId')

console.log('router.index中的角色',_role);
/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    noCache: true                // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect"),
      },
    ],
  },
  {
    path: "/login",
    component: () => import("@/views/login"),
    hidden: true,
  },
  {
    path: "/404",
    component: () => import("@/views/error/404"),
    hidden: true,
  },
  {
    path: "/401",
    component: () => import("@/views/error/401"),
    hidden: true,
  },
  {
    path: "",
    component: Layout,
    redirect: "index",
    children: [
      {
        path: "index",
        component: () => import("@/views/dashboard"),
        name: "首页",
        hidden: true,
        meta: { title: "首页", icon: "dashboard", noCache: true, affix: true },
      },
    ],
  },
  {
    path: "/home",
    component: () => import("@/views/home"),
    hidden: true,
  },
  {
    path: "/system-config",
    component: Layout,
    hidden: false,
    meta: { title: "系统管理", icon: "system" },
    children: [
      {
        path: "baseConfig",
        component: () => import("@/views/config/baseConfig/index"),
        name: "baseConfig",
        meta: { title: "基础信息" },
      },
      {
        hidden:_role>1,
        path: "networkConfig",
        component: () => import("@/views/networkConfig/index"),
        name: "networkConfig",
        meta: { title: "网络参数" },
      },
      {
        hidden:_role>1,
        path: "systemManage",
        component: () => import("@/views/config/systemManage/index"),
        name: "systemManage",
        meta: { title: "系统配置" },
      },
      {
        hidden:_role>1,
        path: "userManagement",
        component: () => import("@/views/config/userManagement/index"),
        name: "userManagement",
        meta: { title: "用户管理" },
      },
      {
        hidden:_role>1,
        path: "escalate",
        component: () => import("@/views/config/escalate/index"),
        name: "escalate",
        meta: { title: "升级维护" },
      },
      // {
      //   path: "test",
      //   component: () => import("@/views/test"),
      //   name: "test",
      //   hidden: false,
      //   meta: { title: "生产检测" },
      // },
      // {
      //   path: "networkBase",
      //   component: () => import("@/views/config/networkBase/index"),
      //   name: "networkBase",
      //   hidden: false,
      //   meta: { title: "网络基础设置" },
      // },
      // {
      //   path: "networkHeight",
      //   component: () => import("@/views/config/networkHeight/index"),
      //   name: "networkHeight",
      //   hidden: false,
      //   meta: { title: "WIFI设置" },
      // },
      // {
      //   path: "outsideSet",
      //   component: () => import("@/views/config/outsideSet/index"),
      //   name: "outsideSet",
      //   hidden: false,
      //   meta: { title: "外显设置" },
      // },
    ],
  },
  {
    hidden:_role>1,
    path: "/network-config",
    component: Layout,
    meta: { title: "" },
    children: [
      {
        path: "/network-config",
        component: () => import("@/views/plugin/pluginConfig"),
        name: "network-config",
        meta: { title: "平台对接", icon: "s-platform" },
      },
    ],
  },
  {
    hidden:_role>1,
    path: "/intelligent",
    component: Layout,
    meta: { title: "" },
    children: [
      {
        path: "/intelligent",
        component: () => import("@/views/intelligent/index"),
        name: "intelligent",
        meta: { title: "智能分析", icon: "dashboard" },
      },
    ],
  },
  // 人员管理
  // {
  //   path: "/person-manage",
  //   name:'person-manage',
  //   component: Layout,
  //   hidden:_role>1,
  //   meta: { title: "" },
  //   redirect:'/person-manage/person',
  //   children: [
  //     {
  //       path: "person",
  //       component: () => import("@/views/person/person/index"),
  //       name: "Person",
  //       meta: { title: "人员管理", icon: "peoples" },
  //     },
  //     {
  //       name: "person-details",
  //       path: "person-details",
  //       hidden: true,
  //       component: () => import("@/views/person/person-details/index"),
  //       meta: { title: "人员详情", icon: "peoples" ,activeMenu:'/person-manage/person-details'},
  //     },
  //   ],
  // },
  {
    path: "/person-list",
    component: Layout,
    meta: { title: "" },
    children: [
      {
        // path: "/personList-aaa",
        path: "/personList",
        name: "personList",
        component: () => import("@/views/personList"),
        meta: { title: "人员管理", icon: "peoples" },
      },
      {
        name: "person-details",
        path: "person-details",
        hidden: true,
        component: () => import("@/views/person/person-details/index"),
        meta: { title: "人员详情", icon: "peoples" ,activeMenu:'/person-manage/person-details'},
      },
    ],
  },

  {
    path: "/visitor",
    component: Layout,
    hidden: false,
    meta: { title: "记录查询", icon: "nested" },
    children: [
      {
        path: "black",
        component: () => import("@/views/person/black/index"),
        name: "Black",
        meta: { title: "抓拍记录" },
      },
      {
        path: "group",
        component: () => import("@/views/person/group/index"),
        name: "Group",
        meta: { title: "识别记录" },
      },
      {
        path: "loginLog",
        component: () => import("@/views/person/loginLog/index"),
        name: "LoginLog",
        meta: { title: "登录记录" },
      },
      {
        path: "openDoor",
        component: () => import("@/views/person/openDoor/index"),
        name: "OpenDoor",
        meta: { title: "开门记录" },
      },
    ],
  },

  {
    path: "/system-parameter",
    component: Layout,
    hidden: true,
    meta: { title: "参数配置", icon: "druid" },
    children: [
      {
        path: "faceParameter",
        component: () => import("@/views/config/faceParameter/index"),
        name: "faceParameter",
        meta: { title: "功能参数", icon: "server" },
      },
      {
        path: "platform",
        component: () => import("@/views/demo/index"),
        hidden: false,
        meta: { title: "平台接入", icon: "row" },
      },
      {
        path: "video-live",
        component: () => import("@/views/config/videoLive/index"),
        name: "videoLive",
        hidden: false,
        meta: { title: "视频预览", icon: "monitor" },
      },
    ],
  },
  {
    path: "/demo-test",
    component: () => import("@/views/demo/index"),
    hidden: true,
    meta: { title: "测试管理" },
  },
];

export default new Router({
  // mode: 'history', // 去掉url中的#
  mode: "hash", //
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes,
});
